package io.gitee.zicai.task.config

import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler

/**
 * ScheduleConfig
 * @author zicai
 * @since 2020-05-18
 */
@Configuration
open class ScheduleConfig {

    @Bean("threadPoolTaskScheduler")
    open fun threadPoolTaskScheduler() : ThreadPoolTaskScheduler {
        return ThreadPoolTaskScheduler().also {
            it.poolSize = 10
            it.threadNamePrefix = "zicai-task-pool-"
            it.setWaitForTasksToCompleteOnShutdown(true)
            it.setAwaitTerminationSeconds(300)
            it.initialize()
        }
    }
}